﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XZL.GM.Dal;


namespace XZL.GM.Bll
{
   public class VideoInfoBiz
    {

        /// <summary>
        /// 获取视频列表
        /// </summary>
        /// <param name="ItemID"></param>
        /// <returns></returns>
       public static List<Proc_CourseItem_SelectListByCourseIDResult> GetVideoList(int courseID, int pageIndex, int pageSize, ref int? pageCount)
        {
          XZL_GMDataContext db = new XZL_GMDataContext();
          return db.Proc_CourseItem_SelectListByCourseID(courseID, pageIndex, pageSize, ref pageCount).ToList();     
        }


       /// <summary>
       /// 获取视频信息 by ItemID
       /// </summary>
       /// <param name="ItemID"></param>
       /// <returns></returns>
       public static Proc_CourseItem_SelectInfoByItemIDResult GetVideoInfo(int courseID)
       {
           XZL_GMDataContext db = new XZL_GMDataContext();

           return db.Proc_CourseItem_SelectInfoByItemID(courseID).FirstOrDefault();

       }



        /// <summary>
        /// 添加视频
        /// </summary>
        /// <param name="ItemID">视频ID</param>

       public static bool VideoAddition(CourseItem courseItem)
       { 
           XZL_GMDataContext db = new XZL_GMDataContext();

           int i = db.Proc_VideoInfo_Addition(courseItem.CourseID, courseItem.ItemName, courseItem.ItemNum, courseItem.VideoLink, 
               courseItem.CourseLength, courseItem.ValidTime, courseItem.StartTime, courseItem.Introduce, courseItem.Image);

           return true;
       
       }

        /// <summary>
        /// 编辑视频
        /// </summary>
        /// <param name="ItemID">用户ID</param>
        /// <returns>    </returns>
        public static bool VideoUpdate(CourseItem courseItem)
       {

           XZL_GMDataContext db = new XZL_GMDataContext();
           db.Proc_VideoInfo_Update(courseItem.ItemID, courseItem.CourseID, courseItem.ItemName, courseItem.ItemNum, courseItem.VideoLink,
               courseItem.CourseLength, courseItem.ValidTime, courseItem.StartTime, courseItem.Introduce, courseItem.Image);

           return true;


       }

        /// <summary>
        /// 删除视频
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool DeleteVideo(int itemID)
        {
            XZL_GMDataContext db = new XZL_GMDataContext();
            db.Proc_VideoInfo_Delete(itemID);
            return true;      
        }



    }



}
